package com.leinao.tensorboard.schedule;

import com.leinao.tensorboard.service.TensorboardService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 *
 */
@Component
@Configuration
@EnableScheduling
public class TensorboardSchedule {

    @Autowired
    private TensorboardService tensorboardService;

    private Logger logger = LoggerFactory.getLogger(TensorboardSchedule.class);

    //每60秒执行一次
    @Scheduled(fixedRate = 1000 * 60)
    public void deleteContainerAuto() {
        try{
            tensorboardService.deleteContainerAuto();
        }catch (Exception e){
            e.printStackTrace();
            logger.error("自动销毁Tensorboard异常：" , e);
        }

    }
}
